<template>
  <div>
    <el-dialog title="详情" :modal-append-to-body="false" :visible.sync="visible">
      <el-table
        :data="dataList"
        border
        v-loading="dataListLoading"
        style="width: 100%;margin-top: 20px"
      >
        <el-table-column align="center" header-align="center" prop="name" label="资源名称"></el-table-column>
<!--        <el-table-column align="center" header-align="center" prop="finishTime" label="完成时间"></el-table-column>-->
        <el-table-column prop="type" header-align="center" align="center" label="资源类型">
          <template slot-scope="scope">
            <span v-if="scope.row.type == 1">图文</span>
            <span v-if="scope.row.type == 2">视频</span>
            <span v-if="scope.row.type == 3">文件</span>
            <span v-if="scope.row.type == 4">作业</span>
            <span v-if="scope.row.type == 5">考试</span>
          </template>
        </el-table-column>
        <el-table-column prop="status" header-align="center" align="center" label="学习状态">
          <template slot-scope="scope">
            <span v-if="scope.row.status == 0">未学习</span>
            <span v-if="scope.row.status == 1">未完成</span>
            <span v-if="scope.row.status == 2">已完成</span>
          </template>
        </el-table-column>
      </el-table>
      <!--      <el-pagination-->
      <!--        @size-change="sizeChangeHandle"-->
      <!--        @current-change="currentChangeHandle"-->
      <!--        :current-page="pageIndex"-->
      <!--        :page-sizes="[10, 20, 50]"-->
      <!--        :page-size="pageSize"-->
      <!--        :total="totalPage"-->
      <!--        layout="total, sizes, prev, pager, next, jumper">-->
      <!--      </el-pagination>-->
      <span slot="footer" class="dialog-footer">
        <el-button @click="visible = false">取消</el-button>
        <el-button type="primary" @click="visible = false" :loading="loading">确定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
  export default {
    data () {
      return {
        visible: false,
        dataListLoading: false,
        pageIndex: 1,
        pageSize: 10,
        totalPage: 0,
        dataList: [],
        records: [],
        dataForm: {
          courseId: '',
          userId: ''
        },
        loading: false
      }
    },

    methods: {
      getDataList () {
        this.dataListLoading = true
        this.$nextTick(() => {
          this.$http({
            url: this.$http.adornUrl(`/train-admin/courseManage/userCourseInfo`),
            method: 'post',
            data: {
              courseId: this.dataForm.courseId,
              userId: this.dataForm.userId
            }
          }).then(res => {
            this.dataList = res.data
            this.dataListLoading = false
          })
        })
      },
      init (id, courseId) {
        this.dataForm.userId = id
        this.dataForm.courseId = courseId
        this.visible = true
        this.getDataList()
      },
      examine (id, checkStatus) {
        this.examVisible = true
        this.$nextTick(() => {
          this.$refs.exam.init(id, checkStatus)
        })
      },
      sizeChangeHandle (val) {
        this.pageSize = val
        this.pageIndex = 1
        this.getDataList()
      },
      currentChangeHandle (val) {
        this.pageIndex = val
        this.getDataList()
      }
    }
  }
</script>

<style scoped>
</style>
